unit contasalterar;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask, DBCtrls;

type
  TFcontasalterar = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    MaskEdit3: TMaskEdit;
    MaskEdit4: TMaskEdit;
    MaskEdit5: TMaskEdit;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure MaskEdit2Exit(Sender: TObject);
    procedure MaskEdit3Exit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Fcontasalterar: TFcontasalterar;

implementation

uses Dados, Contas;

{$R *.dfm}

procedure TFcontasalterar.BitBtn1Click(Sender: TObject);
begin
fdados.contas.edit;
fdados.contasnome.Value         := maskedit2.text;
fdados.contasdata.Value         := strtodate(maskedit3.text);
fdados.contassaldoinicial.Value := strtofloatdef(maskedit4.text,0);
fdados.contassaldoatual.Value   := strtofloatdef(maskedit5.text,0);
fdados.contas.post;
close;
end;

procedure TFcontasalterar.BitBtn2Click(Sender: TObject);
begin
close;
end;


procedure TFcontasalterar.FormShow(Sender: TObject);
begin
maskedit2.setfocus;
maskedit1.text := fdados.contascodigo.value;
maskedit2.text := fdados.contasnome.Value;
maskedit3.text := datetostr(fdados.contasdata.value);
maskedit4.text := floattostr(fdados.contassaldoinicial.value);
maskedit5.text := floattostr(fdados.contassaldoatual.value);

end;

procedure TFcontasalterar.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
   SelectNext(ActiveControl,true,true);
end;



procedure TFcontasalterar.MaskEdit2Exit(Sender: TObject);
begin
if maskedit2.text = '' then
   begin
   showmessage('Nome da conta Invalido');
   beep;
   maskedit2.SetFocus;
   end;
end;



procedure TFcontasalterar.MaskEdit3Exit(Sender: TObject);
begin
  try
  StrToDate(maskedit3.text);
  except
     showmessage('Data invalida');
     maskedit3.setfocus;
  end;

end;

end.
